import axios from "axios";
import { showLoadingToast, closeToast } from "vant";
axios.interceptors.request.use(
  (config) => {
    let token = localStorage.getItem("token");
    if (token) {
      config.headers.Authorization = token;
    }
    showLoadingToast({
      message: "加载中...",
      forbidClick: true,
      loadingType: "spinner",
    });
    return config;
  },
  (error) => {
    return Promise.reject(error);
  }
);
axios.interceptors.response.use(
  (response) => {
    closeToast();
    return response;
  },
  (error) => {
    closeToast();
    return Promise.reject(error);
  }
);
export default axios;
